package com.guichun.delete;

import com.guichun.Jdbcs;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author guichun
 * @version 1.0.0
 * @ClassName JdbcDe.java
 * @email onebigbai@icloud.com
 * @Description JDBC删除
 * @createTime 2021-03-09
 */
public class JdbcDe {
    public JdbcDe(Jdbcs jdbcs) {
        try {
            Connection connection = DriverManager.getConnection(jdbcs.getJdbcUrl(), jdbcs.getJdbcRoot(), jdbcs.getJdbcPassword());

            PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM students WHERE id = ?");
            preparedStatement.setObject(1,34);
            int executeUpdate = preparedStatement.executeUpdate();
            System.out.println("executeUpdate = " + executeUpdate);

        }catch (SQLException e) {
            System.out.println("e = " + e);
        }
    }
}
